﻿using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Dispatcher;
using ServiceInfrastructure.Models.Exceptions;

namespace EconomicInformationServiceWcf.ServiceBehaviours
{
    public class NullParameterInspector : IParameterInspector
    {
        public object BeforeCall(string operationName, object[] inputs)
        {
            if (inputs.Any(input => input == null))
                throw new FaultException<GeneralFault>(new GeneralFault("Request object doesn't specified"));
            return null;
        }

        public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
        {}
    }
}